package com.itheima_0517.array;

import com.itheima_0517.domain.Student;

import java.util.ArrayList;
import java.util.Scanner;

public class Test03 {
    public static void main(String[] args) {
        ArrayList<Student> list = new ArrayList<>();

        Student stu1 = getStudent();
        Student stu2 = getStudent();
        Student stu3 = getStudent();

        list.add(stu1);
        list.add(stu2);
        list.add(stu3);

        for (int i = 0; i < list.size(); i++) {
            Student stu = list.get(i);
            System.out.println(stu.getUsername()+"....."+stu.getAge());
        }
    }

    public static Student getStudent() {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入学生姓名");
        String username = sc.nextLine();
        System.out.println("请输入学生年龄");
        String age = sc.nextLine();
        Student stu = new Student(username,age);
        return stu;
    }
}
